<section id="login" style="width:300px;margin-left:10px;margin-right:10px">
	<h2>Silahkan Login</h2>
	<hr />
	<br />
	<div class="error" style="display:none">Error</div>
	<form id="formlogin" action="<?php echo base_url()?>login.html" class="styled" method="post">	
		<label for="name">Email</label>
		<input class="textbox" type="text" name="email" id="email" />
		
		<label for="name">Password</label>
		<input class="textbox" type="password" name="password" id="password" />
		
		<input type="submit" value="Login!" class="right button" />
		
	</form>
	Lupa Password ? <a id="lupa" href="#" title="<?php echo base_url();?>lupa_password.html" >klik disini</a>
</section>
<section id="forgot" style="width:300px;margin-left:10px;margin-right:10px">
	<h2>Lupa Password</h2>
	<hr />
	<h4>Silahkan masukkan email Anda:</h4>
	<br />
	<div class="error" style="display:none">Error</div>
	<form id="forgotpass" action="<?php echo base_url()?>lupa_password.html" class="styled" method="post">	
		<label for="name">Email</label>
		<input class="textbox" type="text" name="email" id="email" />
		
		<input type="submit" value="Kirim Password!" class="right button" />
		
	</form>
	<br />
</section>
<script>
$("#formlogin").submit(function(){
	var formInput = $(this).serialize();

	$.ajax({
		url: $(this).attr('action'),
		data: formInput,
		beforeSend : function(){
			$.fancybox.showActivity();
			$(".error").hide();
		},
		success: function(respon){
			var obj = jQuery.parseJSON(respon);
			if(obj.status == 'success'){
				window.location = "<?php echo base_url()?>"+obj.url;
			}else{
				$(".error").text(obj.msg);
				$(".error").fadeIn(1000);
			}
			
			$.fancybox.hideActivity();
		},
		type: "POST"
	});
	
	return false;
});

$("#forgotpass").submit(function(){
	var formInput = $(this).serialize();
	
	$.ajax({
		url: $(this).attr('action'),
		data: formInput,
		beforeSend : function(){
			$.fancybox.showActivity();
			$(".error").hide();
		},
		success: function(respon){
			var obj = jQuery.parseJSON(respon);
			if(obj.status == 'success'){
				window.location = "<?php echo base_url()?>"+obj.url;
			}else{
				$(".error").text(obj.msg);
				$(".error").fadeIn(1000);
			}
			
			$.fancybox.hideActivity();
		},
		type: "POST"
	});
	
	return false;
});

$('section#forgot').hide();

$("#lupa").click(function(){

	$('section#login').hide();
	$('section#forgot').show()
	return false;
});
</script>